﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.Master" AutoEventWireup="true" CodeBehind="SiteMembers.aspx.cs" Inherits="JohnnySins.Admin.SiteMembers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <script type="text/javascript">
        $(function () {
            $("#passwordDialog").dialog({ modal: true, autoOpen: false, width: 800, resizable: false });
            $("#passwordDialog").parent().appendTo(jQuery("form:first"));

            $(".ui-dialog-titlebar").hide();
        });

        function showPasswordChange(id)
        {
            $('#tbPassword').val('');
            $('#tbVerifyPassword').val('');
            $('#hdUserId1').val(id);
            $('.passwordValidator').hide();
            $('#passwordDialog').dialog('open');
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="page_title">
        <h1>Site Members</h1>                		
    </div>
    
    <asp:UpdatePanel ID="upList" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
    <div class="row">
        <div class="col-lg-12">
            <div class="display_inputbox_panel">
                <h4>Search</h4>
                <div class="row">
                                	<div class="col-lg-5">
                                        <div class="display_inputbox_content">
        
                                                <div class="form-group">
                                                    <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Name:</label>
                                                    <div class="col-sm-8 col-md-9">
                                                        <asp:TextBox runat="server" ID="txtNameFilter" CssClass="form-control" placeholder="Name"/>
                                                    </div>
                                                </div>
                                                
                                                <div class="form-group">
                                                    <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Email:</label>
                                                    <div class="col-sm-8 col-md-9">
                                                        <asp:TextBox runat="server" ID="txtEmailFilter" CssClass="form-control" placeholder="Email"/>
                                                    </div>
                                                </div>
                                                
                                                <div class="form-group">
                                                    <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Billing:</label>
                                                    <div class="col-sm-8 col-md-9">
                                                        <asp:DropDownList runat="server" ID="ddlPaymentTypeFilter" CssClass="form-control" DataTextField="PaymentTypeName" DataValueField="PaymentTypeId"/>
                                                    </div>
                                                </div>
                                                
                                                <div class="form-group">
                                                    <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Country:</label>
                                                    <div class="col-sm-8 col-md-9">
                                                        <asp:DropDownList runat="server" ID="ddlCountryFilter" CssClass="form-control" DataTextField="CountryName" DataValueField="CountryId"/>
                                                    </div>
                                                </div>
                                                
                                                <div class="form-group">
                                                    <label for="inputname" class="col-sm-4 col-md-3 control-label custom_label">Status:</label>
                                                    <div class="col-sm-8 col-md-9">
                                                        <asp:DropDownList CssClass="form-control" ID="ddlIsActiveFilter" runat="server">
                                                            <asp:ListItem Text="ALL" Value="-1"/>
                                                            <asp:ListItem Text="Active" Value="1"/>
                                                            <asp:ListItem Text="Inactive" Value="0"></asp:ListItem>
                                                        </asp:DropDownList>
                                                    </div>
                                                </div>
                                                                                    
                                        </div>                                        
                                    </div>
                </div>
                <div class="button_group">
                    <asp:Button CssClass="btn btn-info" ID="btnSearch" Text="Search" runat="server" onclick="btnSearch_Click" />
                </div>
            </div>
        </div>
    </div>

    <div class="admin_table_container">
        <h3>Search Result</h3>
                        
        <div class="table-responsive">
            <asp:GridView ID="grid" AutoGenerateColumns="false" runat="server" CssClass="table table-bordered table-hover"
                  AllowPaging="True" PageSize="20" OnRowDataBound="grid_RowDataBound" OnRowCommand="grid_Command" OnPageIndexChanging="grid_PageIndexChanging">
                  <PagerSettings Mode="Numeric" PageButtonCount="4" NextPageText=">" PreviousPageText="<" FirstPageText="<<" LastPageText=">>" />
                  <Columns>
                     <asp:TemplateField HeaderText="Name">
                        <ItemTemplate>
                            <asp:HiddenField ID="hidId" Value='<%#Eval("Id")%>' runat="server" />
                           <asp:Label ID="lblFullName" Text='<%# Eval("FullName") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="User Name">
                        <ItemTemplate>
                           <asp:Label ID="lblUserName" Text='<%# Eval("UserName") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Email">
                        <ItemTemplate>
                           <asp:Label ID="lblEmail" Text='<%# Eval("Email") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Zip Code">
                        <ItemTemplate>
                           <asp:Label ID="lblZip" Text='<%# Eval("Zip") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Country">
                        <ItemTemplate>
                           <asp:Label ID="lblCountryName" Text='<%# Eval("CountryName") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Started">
                        <ItemTemplate>
                           <asp:Label ID="lblCreateDate" Text='<%# Convert.ToDateTime(Eval("CreateDate")).ToString("MM.dd.yyyy") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Billing">
                        <ItemTemplate>
                           <asp:Label ID="lblPaymentTypeName" Text='<%# Eval("PaymentTypeName") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>
                     <asp:TemplateField HeaderText="Status">
                        <ItemTemplate>
                           <asp:Label ID="lblStatusName" Text='<%# Eval("StatusName") %>' runat="server" />
                        </ItemTemplate>
                     </asp:TemplateField>

                     <asp:TemplateField HeaderText="Action">
                        <ItemTemplate>
                           <a href='javascript:void(0)' onclick="javascript:showPasswordChange(<%#Eval("Id")%>);">
                              <img src="<%=ResolveClientUrl("~") %>images/admin/action_icon/password_icon.png" alt="Change Password" title="Change Password"
                                 border="0" />
                           </a>
                        </ItemTemplate>
                     </asp:TemplateField>
                  </Columns>
               </asp:GridView>
        </div>
    </div>

    </ContentTemplate>
    </asp:UpdatePanel>

    <div id="passwordDialog">
            <asp:UpdatePanel runat="server" ID="upChangePassword" UpdateMode="Conditional" ClientIDMode="Static">
            <ContentTemplate>
                <div>
                <div class="fieldset_block col-lg-12 page_area">
                <fieldset>
                    <legend><h4>Change Password</h4></legend>
                    <div class="fieldset_cotent form-horizontal">
                        <asp:HiddenField runat="server" ID="hdUserId1" ClientIDMode="Static"/>
                        <div class="row">
                            <div class="col-lg-12">                                    
                                <div class="form-group">
                                    <label class="col-lg-3 control-label">New Password</label>
                                    <div class="col-lg-3">
                                        <asp:TextBox ID="tbPassword" runat="server" TextMode="Password" CssClass="form-control" ClientIDMode="Static"></asp:TextBox>
                                    </div>
                                    <div class="col-lg-6">
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbPassword" CssClass="validator passwordValidator"
                                            Display="Dynamic" ErrorMessage="Passwor is required" ValidationGroup="changePassword" ForeColor="Red"></asp:RequiredFieldValidator>
                                        <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" ControlToValidate="tbPassword" CssClass="validator passwordValidator"
                                            Display="Dynamic" ErrorMessage="Allow only letters and numbers, from 5 to 15 symbols)" ForeColor="Red"
                                            ValidationExpression="^[a-zA-Z0-9\s]{5,15}$" ValidationGroup="changePassword"></asp:RegularExpressionValidator>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-lg-3 control-label">Verify Password</label>
                                    <div class="col-lg-3">
                                        <asp:TextBox ID="tbVerifyPassword" runat="server" TextMode="Password" CssClass="form-control" ClientIDMode="Static"></asp:TextBox>
                                    </div>
                                    <div class="col-lg-6">
                                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="tbVerifyPassword" CssClass="validator passwordValidator"
                                            Display="Dynamic" ErrorMessage="Verify passwor is required" ValidationGroup="changePassword" ForeColor="Red"></asp:RequiredFieldValidator>
                                        <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToCompare="tbPassword"
                                            ControlToValidate="tbVerifyPassword" Display="Dynamic" 
                                            ErrorMessage="Password and Verify Password values do not match" 
                                            ValidationGroup="changePassword" CssClass="validator passwordValidator" ForeColor="Red"></asp:CompareValidator>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="button_group">
                            <asp:Button CssClass="btn btn-success" ID="btnSavePassword"  ValidationGroup="changePassword" Text="Save" runat="server" OnClick="btnSavePassword_Click" />
                            <asp:Button CssClass="btn btn-info" ID="btnCancelPassword" Text="Cancel" runat="server" OnClientClick="$('#passwordDialog').dialog('close'); return false;" CausesValidation="false" />
                        </div> 
                    </div>
                </fieldset>
                </div>
                </div>
            </ContentTemplate>
            <Triggers>
                <asp:AsyncPostBackTrigger ControlID="btnSavePassword" EventName="Click" />
            </Triggers>
            </asp:UpdatePanel>
    </div>
</asp:Content>
